import axios from './axios-config';

export const listFile = async (): Promise<any> => {
  try {
    const response = await axios.get('/minio/listFile');
    return response.data; // 确保返回的是数据部分
  } catch (error) {
    throw new Error('Failed to fetch file list. Please check the API endpoint.');
  }
};

export const deleteFileByFileObjectName = async (fileObjectName: String): Promise<any> => {
  try {
    const response = await axios.post('/minio/deleteFileByFileObjectName', { 'fileObjectName': fileObjectName });
    return response.data; // 确保返回的是数据部分
  } catch (error) {
    throw new Error('Failed to fetch file list. Please check the API endpoint.');
  }
};

export const deleteFileById = async (id: number): Promise<any> => {
  try {
    const response = await axios.post('/minio/deleteFileById', { 'id': id });
    return response.data; // 确保返回的是数据部分
  } catch (error) {
    throw new Error('Failed to fetch file list. Please check the API endpoint.');
  }
};

export const vectorFileById = async (id: number): Promise<any> => {
  try {
    const response = await axios.post('/minio/vectorFile', { 'id': id });
    return response.data; // 确保返回的是数据部分
  } catch (error) {
    throw new Error('Failed to fetch file list. Please check the API endpoint.');
  }
};